package com.bw.controller;

import com.bw.bean.Sugar1;
import com.bw.bean.Sugar2;
import com.bw.bean.Sugar3;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("/list1")
    public Map getList1(){
        List<Sugar1> list1 = sugarService.getList1();
        return SugarUtil.getLineData(list1);
    }

    @RequestMapping("/list2")
    public Map getList2(){
        ArrayList<String> list = new ArrayList<>();
        List<Sugar2> list2 = sugarService.getList2();
        list.add("课程名称");
        list.add("考试人数");
        list.add("平均分");
        list.add("平均用时");
        return SugarUtil.getTablePlayData(list,list2);
    }

    @RequestMapping("/list3")
    public Map getList3(){
        HashMap map = new HashMap<>();
        double list3 = sugarService.getList3();
        map.put("status",0);
        map.put("data",list3);
        return map;
    }

    @RequestMapping("/list4")
    public Map getList4(){
        ArrayList<String> list = new ArrayList<>();
        List<Sugar3> list4 = sugarService.getList4();
        list.add("课程名称");
        list.add("平均评分");
        list.add("平均人数");
        list.add("好评人数");
        list.add("好评率");
        return SugarUtil.getTablePlayData(list,list4);
    }

    @RequestMapping("/list5")
    public Map getList5(){
        List<Sugar1> list5 = sugarService.getList5();
        return SugarUtil.getLineData(list5);
    }

    @RequestMapping("/list6")
    public Map getList6(){
        ArrayList<String> list = new ArrayList<>();
        List<Sugar2> list6 = sugarService.getList6();
        list.add("题目内容");
        list.add("答题次数");
        list.add("正确答案数");
        list.add("正确率");
        return SugarUtil.getTablePlayData(list,list6);
    }

    @RequestMapping("/list7")
    public Map getList7(){
        ArrayList<String> list = new ArrayList<>();
        List<Sugar2> list7 = sugarService.getList7();
        list.add("试卷名称");
        list.add("考试人数");
        list.add("平均分");
        list.add("平均用时");
        return SugarUtil.getTablePlayData(list,list7);
    }

    @RequestMapping("/list8")
    public Map getList8(){
        List<Sugar1> list8 = sugarService.getList8();
        return SugarUtil.getBarData(list8);
    }
}
